package com.qf.petmall.starter.utils;
import cn.hutool.extra.mail.MailUtil;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException;

/**
 * @Author: 可乐
 * @Description:
 * @CreateTime: 2022-12-11  21:07
 */
@Component
public class Consumer {
	// 这样可以直接指定消息的类型，省略消息格式转换的过程
	@RabbitListener(queues="boot-queue")
	public void getMessage( String msg ) throws UnsupportedEncodingException {
		//调用邮箱发送消息
		sendMessage( msg );

	}

	public void sendMessage( String msg ) {
		//发送邮件是否要封装为一个工具
		MailUtil.send( msg,"验证码",OrderConstants.EMAIL,false );
		System.out.println( msg );
	}
}
